import com.mybatis.mapper.StudentMapper;
import com.mybatis.model.Student;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by xiao zeng on 2017/6/22.
 */
public class student {
    protected SqlSessionFactory ss;
    protected InputStream sf;
    protected SqlSession se;

    @Before
    public void init() {

        try {
            sf = Resources.getResourceAsStream("mybatis-conf.xml");
        } catch (IOException e) {
            e.printStackTrace();
        }
        ss = new SqlSessionFactoryBuilder().build(sf);

        se = ss.openSession();
    }

    @Test
    public void show() {
        StudentMapper sdao = se.getMapper(StudentMapper.class);
        Student s = new Student();
        s.setId(2);

        sdao.updateByPrimaryKey(s);
    }
}
